const state = {
    userInfo: "",
    isLogin: false
}
const getters = {
    getUserInfo(state) {
        if (!state.userInfo) {
            state.userInfo = JSON.parse(localStorage.getItem("userInfo"));
        }
        return state.userInfo;
    },
    getIsLogin(state) {
        if (!state.isLogin) {
            state.isLogin = JSON.parse(localStorage.getItem("isLogin"));
        }
        return state.isLogin;
    }
}
const mutations = {
    setUserInfo(state, obj) {
        state.userInfo = obj;
        localStorage.setItem('userInfo', JSON.stringify(obj));
        state.isLogin = true;
        localStorage.setItem('isLogin', JSON.stringify(true));
    },
    removeUserInfo(state) {
        state.userInfo = "";
        state.isLogin = false;
        localStorage.removeItem('userInfo');
        localStorage.removeItem('isLogin');
    }
}
const actions = {

}
export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
}